#include <iostream>
#include <string>
#include <vector>
#include <pthread.h>
using namespace std;

// 创建多线程

void *routine(void *agrs)
{
    string *name = static_cast<string *>(agrs);
    cout << "创建线程：" << *name << endl;
    return nullptr;
}

int main()
{
    vector<pthread_t> arr;
    for (int i = 0; i < 5; i++)
    {
        pthread_t tid;
        string *name = new string("thread-" + to_string(i));
        pthread_create(&tid, nullptr, routine, name);
        arr.push_back(tid);
    }

    // for (auto &e : arr)
    // {
    //     cout << "线程ID：" << e << endl;
    // }

    for (int i = 0; i < 5; i++)
    {
        int ret = pthread_join(arr[i], nullptr);
        if (ret == 0)
            cout << "等待成功" << endl;
    }
}